﻿Public Class DEstadoTechoPropio
    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String) As List(Of EEstadoTechoPropio)
        Dim estadoTechoPropios As List(Of EEstadoTechoPropio) = Nothing

        Using cn As New SqlConnection(ConfigurationManager.ConnectionStrings(descEmpresa).ConnectionString)
            Using cmd As New SqlCommand("usp_estadoTechoPropio_sel", cn)
                cmd.CommandType = CommandType.StoredProcedure
                Try
                    cn.Open()
                    Using dr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.SingleResult Or CommandBehavior.CloseConnection)
                        If dr.HasRows Then
                            estadoTechoPropios = New List(Of EEstadoTechoPropio)
                            Dim estadoTechoPropio As EEstadoTechoPropio = Nothing
                            Do While dr.Read
                                estadoTechoPropio = New EEstadoTechoPropio( _
                                    dr.GetInt32(dr.GetOrdinal("idEstadoTP")), _
                                    dr.GetString(dr.GetOrdinal("descEstadoTP")), _
                                    dr.GetString(dr.GetOrdinal("estado")), _
                                    dr.GetInt32(dr.GetOrdinal("idUsuario")))
                                estadoTechoPropios.Add(estadoTechoPropio)
                            Loop
                            dr.Close()
                        End If
                    End Using
                Catch ex As Exception
                    Throw
                End Try
            End Using
        End Using

        Return estadoTechoPropios
    End Function
End Class
